const getters = {
  sidebar: state => state.app.sidebar,
  device: state => state.app.device,
  systemMsg: state => state.app.systemMsg,
  token: state => state.sso.token,
  roles: state => state.sso.roles,
  userInfo: state => state.sso.userInfo,
  orgInfo: (state) => {
    const userInfo = state.sso.userInfo
    var organizationVo = userInfo.cacheOrganizationVo
    if (organizationVo) {
      const org = {
        id: organizationVo.id,
        name: organizationVo.organizationName,
        code: organizationVo.organizationCode,
        level: organizationVo.organizationLevel,
        regions: JSON.parse(organizationVo.regions)
      }
      return org
    } else {
      return {}
    }
  },
  deptInfo: (state) => {
    const userInfo = state.sso.userInfo
    var departmentVo = userInfo.cacheDepartmentVo
    if (departmentVo) {
      const dept = {
        id: departmentVo.id,
        name: departmentVo.departmentName,
        code: departmentVo.departmentCode
      }
      return dept
    } else {
      return {}
    }
  },
  orgInfos: state => state.sso.userInfo.cacheOrganizationVos,
  deptInfos: state => state.sso.userInfo.cacheDepartmentVos,
  permission: state => state.sso.permission,
  permission_routers: state => state.permission.routers,
  addRouters: state => state.permission.addRouters
}
export default getters
